<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增曝光台列表')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
    <th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-arrange-add">
            <h4 class="form-header h4">曝光台列表信息</h4>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">曝光标题：</label>
                <div class="col-sm-8">
                    <input name="arrangeTitle" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">开始日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="startDate" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">结束日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="endDate" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">曝光范围：</label>
                <div class="col-sm-3">
                    <div class="input-group">
                        <span class="input-group-addon"><a onclick="javaScript:chooseAllUser();">全员</a></span>
                        <span class="input-group-addon"><a onclick="javaScript:chooseUser();">选择</a></span>
                        <input id="releaseScope" name="releaseScope" class="form-control" type="text" required>
                        <span class="input-group-addon"><a onclick="javaScript:clearUser();">清空</a></span>
                    </div>

                </div>
                <label class="col-sm-2 control-label">参与人数：</label>
                <div class="col-sm-3">
                    <input id="total" name="total" class="form-control" type="number" unselectable="on" readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">站内提示：</label>
                <div class="col-sm-8">
                    <label><input name="websiteTips" type="radio" value="0" />不提示 </label>
                    <label><input name="websiteTips" type="radio" value="1" />提示 </label>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">短信提示：</label>
                <div class="col-sm-8">
                    <label><input name="smsTips" type="radio" value="0" />不提示 </label>
                    <label><input name="smsTips" type="radio" value="1" />提示 </label>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">附件：</label>
                <div class="col-sm-8">
                    <input id="attachments" name="attachments" type="hidden">
                    <div class="file-loading">
                        <input id="file-upload" name="file" class="form-control file-upload" type="file" multiple>
                    </div>
                </div>
            </div>
            <!--<div class="form-group">
                <label class="col-sm-3 control-label">工作状态：</label>
                <div class="col-sm-8">
                    <label><input name="status" type="radio" value="0" />草稿 </label>
                    <label><input name="status" type="radio" value="1" />已发布 </label>
                </div>
            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remark" class="form-control" type="text">
                </div>
            </div>
            <!--<div class="form-group">
                <label class="col-sm-3 control-label is-required">发起人ID：</label>
                <div class="col-sm-8">
                    <input name="userId" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">发起人：</label>
                <div class="col-sm-8">
                    <input name="userName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">发起人部门ID：</label>
                <div class="col-sm-8">
                    <input name="deptId" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">发起人部门：</label>
                <div class="col-sm-8">
                    <input name="deptName" class="form-control" type="text" required>
                </div>
            </div>-->
            <!--<h4 class="form-header h4">查看进度信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>-->
        </form>
        <div class="row">
            <div class="col-sm-offset-5 col-sm-10">
                <button type="button" class="btn btn-sm btn-success" onclick="submitHandler()"><i class="fa fa-plus"></i>暂 存</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler1()"><i class="fa fa-check"></i>发 布</button>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <th:block th:include="include :: summernote-js" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "exposure/arrange"
        $("#form-arrange-add").validate({
            focusCleanup: true
        });

        //暂存
        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-arrange-add').serialize());
            }
        }

        //发布
        function submitHandler1() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add1", $('#form-arrange-add').serialize());
            }
        }

        // 编辑器上传文件
        function sendFile(file, obj) {
            var data = new FormData();
            data.append("file", file);
            $.ajax({
                type: "POST",
                url: ctx + "common/upload",
                data: data,
                cache: false,
                contentType: false,
                processData: false,
                dataType: 'json',
                success: function (result) {
                    if (result.code == web_status.SUCCESS) {
                        $(obj).summernote('editor.insertImage', result.url, result.fileName);
                    } else {
                        $.modal.alertError(result.msg);
                    }
                },
                error: function (error) {
                    $.modal.alertWarning("图片上传失败。");
                }
            });
        }

        // 附件上传初始化
        $(function(){
            initUploadFileInfo("attachments", "file-upload", [], "");
        })

        function chooseAllUser() {
            $("#releaseScope").val(page_constants.ALL_USER)
            $.ajax({
                type: "POST",
                url: ctx + "common/activeUserCount",
                error: function (request) {
                    $.modal.alertError("系统错误");
                },
                success: function (data) {
                    $("#total").val(data.data);
                }
            });
        }

        function chooseUser() {
            $.modal.open("选择用户", ctx + "common/chooseUser");
        }

        function clearUser() {
            $("#releaseScope").val("");
            $("#total").val(0);
        }

        $("input[name='startDate']").datetimepicker({
            format: "yyyy-mm-dd hh:ii",
            minView: "0",
            autoclose: true
        });

        $("input[name='endDate']").datetimepicker({
            format: "yyyy-mm-dd hh:ii",
            minView: "0",
            autoclose: true
        });

        $(function() {
            var options = {
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'arrangeName',
                    align: 'center',
                    title: '曝光标题',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='exposureProgressList[%s].arrangeName' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'receiveUserId',
                    align: 'center',
                    title: '接收人ID',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='exposureProgressList[%s].receiveUserId' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'receiveUser',
                    align: 'center',
                    title: '接收人',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='exposureProgressList[%s].receiveUser' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'receiveDeptId',
                    align: 'center',
                    title: '接收部门ID',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='exposureProgressList[%s].receiveDeptId' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'receiveDept',
                    align: 'center',
                    title: '接收部门',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='exposureProgressList[%s].receiveDept' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'receiveTime',
                    align: 'center',
                    title: '查看时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='exposureProgressList[%s].receiveTime' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'status',
                    align: 'center',
                    title: '工作状态',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='exposureProgressList[%s].status' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'createBy',
                    align: 'center',
                    title: '创建者',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='exposureProgressList[%s].createBy' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'createTime',
                    align: 'center',
                    title: '创建时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='exposureProgressList[%s].createTime' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'updateBy',
                    align: 'center',
                    title: '更新者',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='exposureProgressList[%s].updateBy' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'updateTime',
                    align: 'center',
                    title: '更新时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='exposureProgressList[%s].updateTime' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'remark',
                    align: 'center',
                    title: '备注',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='exposureProgressList[%s].remark' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'userId',
                    align: 'center',
                    title: '发起人ID',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='exposureProgressList[%s].userId' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'userName',
                    align: 'center',
                    title: '发起人',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='exposureProgressList[%s].userName' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'deptId',
                    align: 'center',
                    title: '发起人部门ID',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='exposureProgressList[%s].deptId' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'deptName',
                    align: 'center',
                    title: '发起人部门',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='exposureProgressList[%s].deptName' value='%s'>", index, value);
                        return html;
                    }
                
                }]
            };
            $.table.init(options);
        });

        function addColumn() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            sub.editColumn();
        	
            $("#" + table.options.id).bootstrapTable('insertRow', {
                index: count,
                row: {
                    index: $.table.serialNumber(count),
                    arrangeName: "",
                    receiveUserId: "",
                    receiveUser: "",
                    receiveDeptId: "",
                    receiveDept: "",
                    receiveTime: "",
                    status: "",
                    createBy: "",
                    createTime: "",
                    updateBy: "",
                    updateTime: "",
                    remark: "",
                    userId: "",
                    userName: "",
                    deptId: "",
                    deptName: ""
                }
            });
        }
    </script>
</body>
</html>